import 'package:flutter/material.dart';
import 'package:huobi/configs/app_style_config.dart';
import 'package:huobi/views/jk/jk_text.dart';

class HomeSearchPage extends StatefulWidget {
  @override
  _HomeSearchPageState createState() => _HomeSearchPageState();
}

class _HomeSearchPageState extends State<HomeSearchPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: AppStyleConfig.themColor,
      appBar: _appBar(),
      body: ListView(
        children: [],
      ),
    );
  }

  // AppBar
  Widget _appBar() {
    return AppBar(
      backgroundColor: AppStyleConfig.themColor,
      titleSpacing: 0.0,
      elevation: 0.0,
      automaticallyImplyLeading: false,
      title: Container(
          margin: EdgeInsets.only(left: 16.0),
          height: 30,
          decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(20), color: Colors.black12),
          child: buildTextField()),
      actions: [
        FlatButton(
          onPressed: () {
            Navigator.pop(context);
          },
          child: JKText(
            data: "取消",
            fontSize: 12,
            color: Colors.white70,
          ),
        ),
      ],
    );
  }

  Widget buildTextField() {
    return ConstrainedBox(
      constraints:BoxConstraints(maxHeight: 30,minHeight: 30),
      child: TextField(
        autofocus:true,
        decoration: InputDecoration(
          // contentPadding: const EdgeInsets.symmetric(vertical: 10.0),
          border: InputBorder.none, // 去掉下滑线
          counterText: '',// 去除输入框底部的字符计数
          hintText: "搜索您关心的币种",
          alignLabelWithHint: true,
          hintStyle: TextStyle(color: Colors.white70,fontSize: 12),
          prefixIcon: Icon(Icons.search_rounded,color: Colors.white70,),

        ),
        // cursorHeight: 12,
        // controller: controller,
        maxLength: 30,  //最大长度，设置此项会让TextField右下角有一个输入数量的统计字符串
        maxLines: 1,   //最大行数
        textAlign: TextAlign.left,        //文本对齐方式
        style: TextStyle(fontSize: 12.0, color: Colors.white70,textBaseline: TextBaseline.alphabetic),
        onChanged: (text) {
          //内容改变的回调
          print('change $text');
        },
        onSubmitted: (text) {
          //内容提交(按回车)的回调
          print('submit $text');
        },
        enabled: true, //是否禁用
      ),
    );
  }
}
